package demo1;

public class Test {
    public static MysingleList.ListNode mergeTwoLists(MysingleList.ListNode list1, MysingleList.ListNode list2) {
        MysingleList.ListNode newHead = new MysingleList.ListNode(-1111);
        MysingleList.ListNode tmp = newHead;
        while(list1 != null && list2 != null){
            if(list1.val < list2.val){
                tmp.next = list1;
                tmp = tmp.next;
                list1 = list1.next;
            }else{
                tmp.next = list2;
                tmp = tmp.next;
                list2 = list2.next;
            }
        }
        if(list1 == null){
            tmp.next = list2;
        }
        if(list2 == null){
            tmp.next = list1;
        }
        return newHead.next;

    }

    public static void main(String[] args) {
        MysingleList mysingleList1 = new MysingleList();
        MysingleList mysingleList2 = new MysingleList();
        mysingleList1.addFirst(12);
        mysingleList1.addFirst(11);
        mysingleList1.addFirst(10);
        mysingleList1.addFirst(7);
        mysingleList2.addFirst(54);
        mysingleList2.addFirst(45);
        mysingleList2.addFirst(23);
        mysingleList2.addFirst(1);
        MysingleList.ListNode c = mergeTwoLists(mysingleList1.head,mysingleList2.head);
        mysingleList2.show();


    }
    public static void main1(String[] args) {
        MysingleList mysingleList = new MysingleList();
        mysingleList.createList();
        int a = mysingleList.size();
        System.out.println(a);
        boolean b = mysingleList.contains(45);
        System.out.println(b);
        mysingleList.addFirst(999);
        mysingleList.addFirst(999);
        mysingleList.addFirst(999);
        mysingleList.addFirst(999);
        mysingleList.addFirst(999);
        mysingleList.addLast(888);
        mysingleList.show();
        mysingleList.reverseList();
        mysingleList.show();
        MysingleList.ListNode node = mysingleList.middleNode();
        System.out.println(node.val);
        mysingleList.show();
        MysingleList.ListNode c = mysingleList.findKthToTail(10);
        System.out.println(c.val);
    /*mysingleList.addIndex(1,6666);
        mysingleList.show();
        mysingleList.remove(12);
        mysingleList.show();
        mysingleList.removeAllKey(999);
       // mysingleList.clear();
        mysingleList.show();
        mysingleList.reverseList(mysingleList.head);
        mysingleList.show();
*/

    }
}
